<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<?php
require_once 'class/db.php';
require_once 'class/keyword.php';
require_once 'class/words.php';
require_once 'function.php'
?>
<?php
$keywords = new works();
$list = $keywords->selects();
?>

<from method='GET'>
    <?php
    $page = 1;
      if (isset($_GET['page']))
              $page = $_GET['page']
    ?>
    <a href='indexw.php?page=<?php echo $page['page']-1?>'> Prew </a>
    <a href='indexw.php?page=1'> First</a>
    <?php
    
    $page = 5;
   
    if ((isset($_GET['page'])) &&($page['page'] <= 3)) {
        for ($i = 1; $i <= $page; $i++) {
            ?> 
            <a href='indexw.php?page=<?php echo $i ?>'><?php echo $i ?></a>
        <?php
        }
    } else if ((isset($_GET['page'])) &&($page['page'] >= 17)) {
        for ($i = 15; $i <= 19; $i++) {
            ?> 
            <a href='indexw.php?page=<?php echo $i ?>'><?php echo $i ?></a>
        <?php }
    } else if (isset($_GET['page'])) {
        for ($i = ($_GET['page'] - 2); $i <= ($page['page'] + 2); $i++) {
            ?>
            <a href='indexw.php?page=<?php echo $i ?>'><?php echo $i ?></a>
    <?php }
} ?>
    <a href='indexw.php?page=19'>Last</a>
     <a href='indexw.php?page=<?php echo $page['page'] + 1?>'> Next </a>
</table>
</from>
<?php
$page = 1;
if (isset($_GET['page']))
    $page = $_GET['page'];
$from = PER_PAGE * ($page - 1);
$to = PER_PAGE;
$query = "SELECT * FROM works LIMIT $from ,$to";
$list = $keywords->select($query);
?>
</from>
<table border="1px">
    <tr>
        <td>ID</td>
        <td>Name</td>
        <td>URL</td>
        <td>Qption</td> 
    </tr>
<?php foreach ($list as $lists) : ?> 
        <tr>
            <td><?php echo $lists['id']; ?></td>
            <td><?php echo $lists['name']; ?></td>
            <td><a href='<?php echo $lists['url']; ?>'><?php echo $lists['url']; ?></td>
            <td><img src="images/Hydrangeas.jpg" width ="12px" height="12px"><a href='edit.php?page='> Edit</a><br>
        </tr>
                <?php endforeach; ?>
</table>
